<%@ page import="service.serviceimpl.ServiceUserImpl" %>
<%@ page import="entity.Userinfo" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        .bh{
            color: red;
        }
    </style>
</head>
<body>
<%
    ServiceUserImpl serviceUser = new ServiceUserImpl();
    //总条数
    int totalcounts=0;
    //总页数
    int pages;
    //当前页
    int currentPage=1;
    if(request.getParameter("currentPage")!=null){
        currentPage= Integer.parseInt(request.getParameter("currentPage"));
    }
    //每页展示数
    int pageSize=2;
    totalcounts= serviceUser.load("select count(1) from userinfo");
    pages=totalcounts%pageSize==0?totalcounts/pageSize:totalcounts/pageSize+1;
    //out.print(pages);
    List<Userinfo> userinfos =
            serviceUser.executeQuery("select * from userinfo limit ?,?",(currentPage-1)*pageSize,pageSize);

%>
<table border="4">
    <tr>
        <th>id</th>
        <th>name</th>
        <th>sex</th>
        <th>op</th>
    </tr>
    <% for(Userinfo xjj : userinfos){%>
    <tr>
        <td><%=xjj.getId()%></td>
        <td><%=xjj.getName()%></td>
        <td><%=xjj.getSex()==1?"男":"女"%></td>
        <td>删除|修改</td>
    </tr>
    <%}%>
</table>
 当前页/总页数:<%=currentPage%>/<%=pages%>
<a href="page163.jsp?currentPage=1">首页</a>
<a   <%=currentPage-1<1?"hidden":""%>    href="page163.jsp?currentPage=<%=currentPage-1%>">上一页</a>
<a <%=currentPage+1>pages?"hidden":""%> href="page163.jsp?currentPage=<%=currentPage+1%>">下一页</a>
<a href="page163.jsp?currentPage=<%=pages%>">尾页</a>
<br>
<%
    for(int i=1;i<=pages;i++){
        %>
        <a <%=currentPage==i?"class=\"bh\"":""%> href="page163.jsp?currentPage=<%=i%>"><%=i%>&nbsp;&nbsp;</a>

   <%
    }
%>
</body>
</html>
